export default {
  // 国际标准时间转YYMMDD
  formYYMMDD(date: any) {
    const year = date.getFullYear();
    const month = date.getMonth() + 1;
    const day = date.getDate();
    return `${year}-${this.toTwoBitStr(month)}-${this.toTwoBitStr(day)}`;
  },
  toTwoBitStr(number: number) {
    return number > 9 ? number : '0' + number;
  },
  fixAddressValue(list: any) {
    return list.map(({label, value, children}) => {
      if (Array.isArray(children)) {
        return {
          value: label,
          label,
          children: this.fixAddressValue(children),
        };
      }
      return {
        value: label,
        label,
      };
    });
  },
};
